package com.maoyongqi.sockjs方式.job;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;

@Configuration
public class MyJob {

    @Autowired
    SimpMessagingTemplate simpMessagingTemplate;


    @Scheduled(fixedDelay = 2000)
    public void sendMessage(){
        System.out.println("正在发送字段到客户端");
        simpMessagingTemplate.convertAndSend("/server/sendMessageByServer", System.currentTimeMillis());
    }
}
